/* 
 * AP(r) Computer Science GridWorld Case Study:
 * Copyright(c) 2005-2006 Cay S. Horstmann (http://horstmann.com)
 *
 * This code is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * @author Chris Nevison
 * @author Barbara Cloud Wells
 * @author Cay Horstmann
 */
import info.gridworld.grid.Grid;
import info.gridworld.grid.Location;

import java.util.ArrayList;

public class QuickCrab extends CrabCritter {
	public QuickCrab() {
		// TODO Auto-generated constructor stub
	}

	public ArrayList<Location> getMoveLocations() {
		ArrayList<Location> locs = new ArrayList<Location>();
		Grid grid = getGrid();
		Location loc = getLocation();
		int dir = getDirection() + Location.LEFT;

		Location left_loc = loc.getAdjacentLocation(dir);
		if (grid.isValid(left_loc) && grid.get(left_loc) == null) {
			dir = getDirection() + Location.LEFT;
			Location againLeft_loc = left_loc.getAdjacentLocation(dir);
			if (grid.isValid(againLeft_loc) && grid.get(againLeft_loc) == null) {
				locs.add(againLeft_loc);
			}
		}

		dir = getDirection() + Location.RIGHT;
		Location right_loc = loc.getAdjacentLocation(dir);
		if (grid.isValid(right_loc) && grid.get(right_loc) == null) {
			dir = getDirection() + Location.RIGHT;
			Location againRight_loc = right_loc.getAdjacentLocation(dir);
			if (grid.isValid(againRight_loc) && grid.get(againRight_loc) == null) {
				locs.add(againRight_loc);
			}
		}

		return locs;
	}

}
